

import Vue from 'vue'
import VueRouter from 'vue-router'
import axios from './netapi'
import VueAxios from 'vue-axios'
import Vuex from 'vuex'
import global from './g'




import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './css/index.scss'



//安装vue模块
Vue.use(VueRouter)
Vue.use(ElementUI);
Vue.use(VueAxios, axios);
Vue.use(Vuex)


import router from './router'
//导入组件
import App from './App.vue'
import videoCard from './components/video-card.vue'
import myList from './components/my-list.vue'
import myListItem from './components/my-list-item.vue'
import myCollapse from './components/my-collapse.vue'
import commentPost from './components/comment-post.vue'
import commentItem from './components/comment-item.vue'
import myPhoto from './components/my-photo.vue'
import videoItem from './components/video-item.vue'


Vue.component('videoCard', videoCard) //全局注册通用视频卡片组件
Vue.component('videoItem',videoItem) //横向视频列表组件
Vue.component('myList', myList) //全局注册 my-list列表组件
Vue.component('myListItem', myListItem) //全局注册 my-list-item组件
Vue.component('myCollapse', myCollapse) //自定义下拉展开组件
Vue.component('comment-post', commentPost)//发布评论组件
Vue.component('comment-item',commentItem)//评论项组件
Vue.component('my-photo',myPhoto) //头像组件
//引入全局变量
Vue.prototype.GLOBAL = global

const store = new Vuex.Store({
    state: {
        user: null
    },
    mutations: {
        setUser(state,user) {
            state.user=user
        },
        removeUser(state){
            state.user = null
        }
    }
})



var vm = new Vue({
    el: "#app",
    data: {
        msg: "666"
    },
    created:function(){
        if(localStorage.getItem("userData")==='undefined') return;
        
        this.$store.commit("setUser",JSON.parse(localStorage.getItem("userData")))
    },
    mounted:function(){
       
    },
    render: c => c(App),
    router,
    store
})